'''
Created on Jul 9, 2011

@author: kafkef
'''

from PyQt4.QtGui import *
from PyQt4.QtCore import QObject, SLOT, SIGNAL, pyqtSlot, QSize

from dexen.system.client.ui.job_main import JobWidget
from dexen.system.client.ui.conn_widget import ConnectionWidget


class MainWidget(QWidget):
    def __init__(self):
        QWidget.__init__(self)
        # Create the widgets
        self._conn_widget = ConnectionWidget()
        self._job_widget = JobWidget()
        # Configure the widgets
        self._job_widget.setEnabled(False)   
        # Lay out the widgets
        layout = QVBoxLayout()
        layout.addWidget(self._conn_widget)
        layout.addWidget(self._job_widget)
        self.setLayout(layout)
        # Configure the signal/slot connections
        QObject.connect(self._conn_widget, SIGNAL("server_connected()"),
                        self.on_server_connected)
                        
    def on_server_connected(self):
        print "server connected"
        self._job_widget.setEnabled(True)
        self._job_widget.on_server_connected()
    
    def on_refresh(self):
        print "refresh is clicked"
        self._job_widget.on_job_refresh()

